package cn.uway.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import cn.uway.Application;
import cn.uway.interceptor.AuthInterceptor;
import cn.uway.properties.ShiroProperties;

/**
* 配置拦截器,校验登录的TOKEN是否被刷新
*/
@Configuration
@ComponentScan(basePackageClasses = Application.class, useDefaultFilters = true)
public class InterceptorsConfig extends WebMvcConfigurerAdapter {

    static final private String FAVICON_URL = "/favicon.ico";

    @Autowired 
    private ShiroProperties shiroProperties;
   
   
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    	System.out.println("=============addInterceptors   shiroProperties.getLoginUrl()="+shiroProperties.getLoginUrl());
        registry.addInterceptor(new AuthInterceptor(shiroProperties.getLoginUrl()))
                .addPathPatterns("/**")
                .excludePathPatterns(FAVICON_URL, "/static/**", "/error", shiroProperties.getLoginUrl())
        ;
    }

}